/*
 *             Copyright (C) 2024 Steve Jrong
 *
 * 	   GitHub Homepage: https://www.github.com/SteveJrong
 *      Gitee Homepage: https://gitee.com/stevejrong1024
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.stevejrong.waiter.common.component.log;

import java.util.Collection;
import java.util.Map;

import lombok.NoArgsConstructor;

/**
 * 工具类 - 日志
 *
 * @author Steve Jrong
 * @since 1.0
 */
@NoArgsConstructor
public final class LogUtil {

    /**
     * 从键值构建单条目日志
     *
     * @param map Map集合
     * @return 可用于日志输出的最终字符串
     */
    public static String format(Map<String, ?> map) {
        return (new LogBuilder(map)).toString();
    }

    /**
     * 从键值构建单条目日志
     *
     * @param key        字符串类型的键
     * @param collection 集合类型的值
     * @return 可用于日志输出的最终字符串
     */
    public static String format(String key, Collection<?> collection) {
        return (new LogBuilder(key, collection)).toString();
    }

    /**
     * 从键值构建单条目日志
     *
     * @param key   字符串类型的键
     * @param value 任意类型的值
     * @return 可用于日志输出的最终字符串
     */
    public static String format(String key, Object value) {
        return (new LogBuilder(key, value)).toString();
    }

    /**
     * 创建一个日志构建器实例
     *
     * @return 日志构建器实例
     */
    public static LogBuilder builder() {
        return new LogBuilder();
    }

    /**
     * 从构建器输出可用于日志的最终字符串
     *
     * @param logBuilder 日志构建器实例
     * @return 可用于日志输出的最终字符串
     */
    public static String toString(LogBuilder logBuilder) {
        return logBuilder.toString();
    }
}